<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>mywork</title>
		 <link href="../assets/css/bootstrap.css" rel="stylesheet" />
		 <link href="../assets/css/select2.min.css" rel="stylesheet" >
	     <!-- FontAwesome Styles-->
	    <link href="../assets/css/font-awesome.css" rel="stylesheet" />
	    <link href="../css/pulic.css" rel="stylesheet"/>
	     <!-- Google Fonts-->
	   <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
	     <!-- TABLE STYLES-->
	    <link href="../assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
	    <script src="../js/layui/layui.js"></script>  
		 <style media="screen">
        	.ECalendar{width:120px;height:30px;}
    	</style>
	</head>
	<body>
		<!--<div class="panel panel-default">-->
                   <div class="row" style="margin-left: 23%;margin-top:2%">
						<form class="form-inline" >
							<div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName1" placeholder="请输入员工编号">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName1" placeholder="请输入员工姓名">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName2" placeholder="请输入所属部门">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName3" placeholder="请输入职级">
                            </div>
							<div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName3" placeholder="请输入所属公司">
                            </div>
                            <button type="submit" class="btn btn-info">搜索</button>
                        </form>
					</div>
					 
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>员工编号</th>
                                            <th>员工姓名</th>
                                            <th>所属部门</th>
                                            <th>职级</th>
                                            <th>所属公司</th>
                                            <th>联系方式</th>
											<th>银行帐号</th>
                                            <th>修改密码</th>
                                            <th>再次输入密码</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    	<!--以下需要重复使用的部分-->
                                        <tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard" id="phoneNum" onblur="checkPhone()" placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
                                     <!--以上需要重复使用的部分-->
                                        <tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
										<tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
										<tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
										<tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
                                         <tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
                                       <tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
                                         <tr>
                                            <td>1001</td>
                                            <td>张三</td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属部门"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入职级"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入所属公司"></td>
                                            <td><input type="text" class="form-control input-text size-S inputCard"  placeholder="请输入联系方式"></td>
											<td><input type="text" class="form-control input-text size-S inputCard" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号"></td>
                                            <td><input type="text" class="form-control"placeholder="请输入新密码"></td>
                                            <td><input type="text" class="form-control"placeholder="请再次输入密码"></td>
                                            <td><a href="#" class="btn btn-danger">删除</a>
                                           	<a href="#" class="btn btn-warning">修改</a>
                                             <a href="#" class="btn btn-info">取消</a></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!--分页功能-->
                         <div class="row" style="margin-left: 25%;margin-bottom:1%">
                   	<div class="col-sm-6">
                   		<div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
                   			<ul class="pagination">
                   				<li class="paginate_button previous" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_previous"><a href="#">Previous</a></li>
                   				<li class="paginate_button active" aria-controls="dataTables-example" tabindex="0"><a href="#">1</a></li>
                   				<li class="paginate_button " aria-controls="dataTables-example" tabindex="0"><a href="#">2</a></li>
                   				<li class="paginate_button " aria-controls="dataTables-example" tabindex="0"><a href="#">3</a></li>
                   				<li class="paginate_button " aria-controls="dataTables-example" tabindex="0"><a href="#">4</a></li>
                   				<li class="paginate_button " aria-controls="dataTables-example" tabindex="0"><a href="#">5</a></li>
                   				<li class="paginate_button " aria-controls="dataTables-example" tabindex="0"><a href="#">6</a></li>
                   				<li class="paginate_button next" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_next"><a href="#">Next</a></li>
                   			</ul>
                   		</div>
                   	</div>
                   </div>
                    <!--新增功能-->
                   <div class="row" style="margin-left: 4%;">
						<form class="form-inline" >
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName1" placeholder="请输入员工姓名">
                            </div>
                            <div class="form-group"> 
                            	<input type="text" class="form-control" id="exampleInputName2" placeholder="输入所属部门">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName3" placeholder="请输入职称">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName4" placeholder="请输入所属公司">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control"  id="phoneNum" onblur="checkPhone()" placeholder="请输入联系方式">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="bankCardNumber"  name="bankCardNumber" onblur="getNum()" placeholder="请输入银行卡号">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName7" placeholder="请设置密码">
                            </div>
                            <div class="form-group">                      
                                <input type="text" class="form-control" id="exampleInputName8" placeholder="请再次输入密码">
                            </div>
                           <button type="submit" class="btn btn-primary">新增</button>
                        </form>
					</div>
                   
	</body>
</html>
 	<script src="../assets/js/jquery-1.10.2.js"></script>
	
      	
      <!-- Bootstrap Js -->
    <script src="../assets/js/bootstrap.min.js"></script>
    <script src="../assets/js/select2.full.min.js"></script>
    <!-- Metis Menu Js -->
    <script src="../assets/js/jquery.metisMenu.js"></script>
     <!-- DATA TABLE SCRIPTS -->
    <script src="../assets/js/dataTables/jquery.dataTables.js"></script>
    <script src="../assets/js/dataTables/dataTables.bootstrap.js"></script>
         <!-- Custom Js -->
    <script src="../assets/js/custom-scripts.js"></script>
    <script src="../js/Ecalendar.jquery.min.js"></script>
    <script src="../assets/js/select2.full.min.js"></script>
	<script type="text/javascript">
	$(document).ready(function() {
	  $(".selectbox").select2();
	});
	</script>
      <!-- Custom Js -->
    <script src="../assets/js/custom-scripts.js"></script>
    <script>
    	
    	
    	//得到输入的银行卡号
    	function getNum(){
    	 var bankCardNumber = $("#bankCardNumber").val();//银行卡的id应该是动态id
    	 CheckBankNo(bankCardNumber);
    	}
    	
    	
    	
    	
//银行卡号Luhn校验算法
//luhn校验规则：16位银行卡号（19位通用）: 
//1.将未带校验位的 15（或18）位卡号从右依次编号 1 到 15（18），位于奇数位号上的数字乘以 2。
//2.将奇位乘积的个十位全部相加，再加上所有偶数位上的数字。
//3.将加法和加上校验位能被 10 整除。

//bankno为银行卡号
 function luhnCheck(bankno){
     var lastNum=bankno.substr(bankno.length-1,1);//取出最后一位（与luhn进行比较）
 
     var first15Num=bankno.substr(0,bankno.length-1);//前15或18位
     var newArr=new Array();
     for(var i=first15Num.length-1;i>-1;i--){    //前15或18位倒序存进数组
         newArr.push(first15Num.substr(i,1));
     }
     var arrJiShu=new Array();  //奇数位*2的积 <9
     var arrJiShu2=new Array(); //奇数位*2的积 >9
     
     var arrOuShu=new Array();  //偶数位数组
     for(var j=0;j<newArr.length;j++){
         if((j+1)%2==1){//奇数位
             if(parseInt(newArr[j])*2<9)
             arrJiShu.push(parseInt(newArr[j])*2);
             else
             arrJiShu2.push(parseInt(newArr[j])*2);
         }
         else //偶数位
         arrOuShu.push(newArr[j]);
     }
     
     var jishu_child1=new Array();//奇数位*2 >9 的分割之后的数组个位数
     var jishu_child2=new Array();//奇数位*2 >9 的分割之后的数组十位数
     for(var h=0;h<arrJiShu2.length;h++){
         jishu_child1.push(parseInt(arrJiShu2[h])%10);
         jishu_child2.push(parseInt(arrJiShu2[h])/10);
     }        
     
     var sumJiShu=0; //奇数位*2 < 9 的数组之和
     var sumOuShu=0; //偶数位数组之和
     var sumJiShuChild1=0; //奇数位*2 >9 的分割之后的数组个位数之和
     var sumJiShuChild2=0; //奇数位*2 >9 的分割之后的数组十位数之和
     var sumTotal=0;
     for(var m=0;m<arrJiShu.length;m++){
         sumJiShu=sumJiShu+parseInt(arrJiShu[m]);
     }
     
     for(var n=0;n<arrOuShu.length;n++){
         sumOuShu=sumOuShu+parseInt(arrOuShu[n]);
     }
     
     for(var p=0;p<jishu_child1.length;p++){
         sumJiShuChild1=sumJiShuChild1+parseInt(jishu_child1[p]);
         sumJiShuChild2=sumJiShuChild2+parseInt(jishu_child2[p]);
     }      
     //计算总和
     sumTotal=parseInt(sumJiShu)+parseInt(sumOuShu)+parseInt(sumJiShuChild1)+parseInt(sumJiShuChild2);
     
     //计算luhn值
     var k= parseInt(sumTotal)%10==0?10:parseInt(sumTotal)%10;        
     var luhn= 10-k;
     
     if(lastNum==luhn){
        console.log("验证通过");
         return true;
     }else{
        layer.msg("银行卡号必须符合luhn校验");
         return false;
     }        
 }
 //使用layui声明
 layui.use('layer', function(){
  			var layer = layui.layer;
  		});  

 //检查银行卡号
 function CheckBankNo(bankno) {
     var bankno = bankno.replace(/\s/g,'');
     if(bankno == "") {
         layer.msg("请填写银行卡号");
         return false;
     }
     if(bankno.length < 16 || bankno.length > 19) {
         layer.msg("银行卡号长度必须在16到19之间");
         return false;
     }
     var num = /^\d*$/;//全数字
     if(!num.exec(bankno)) {
         layer.msg("银行卡号必须全为数字");
         return false;
     }
     //开头6位
     var strBin = "10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99";
     if(strBin.indexOf(bankno.substring(0, 2)) == -1) {
         layer.msg("银行卡号开头6位不符合规范");
         return false;
     }
     //Luhn校验
     if(!luhnCheck(bankno)){
         return false;
     }
     return true;
 }
 
 
 
 //验证电话号码
 function checkPhone(){
 	var phoneNum = $("#phoneNum").val();
 	if(phoneNum == "" ){ 
        layer.msg("手机号码为空，请填写!");
        return;
    }else if(!(/^1[34578]\d{9}$/.test(phoneNum))){ 
        layer.msg("手机号码有误，请重填!");  
      
    } 
 }
    </script>